from moviepy.editor import *
from common.video_tools import animation_and
from animation.editor import *

'''
8.	视频+图片动画
'''
if __name__ == '__main__':
    output_file_path = '../results/example08.mp4'
    hzwVideoClip = VideoFileClip('../videos/hzw_part.mp4')
    imageClip = ImageClip('../videos/dw.png')
    animationClip = imageClip.set_position((60, 60)).set_duration(13.8)
    animationClip = animationClip.crossfadein(duration=2)
    animations = [{"start": 3, "duration": 4, "func": "move_line(point2=(900,300))"},
                  {"start": 6.9, "duration": 4, "func": "move_screw_spin(point2=(200,200),r=5,n=10)"},
                  {"start": 10.8, "duration": 3, "func": "erase_out()"}]
    for animation in animations:
        animationClip = animation_and(animationClip, [animation], bg_size=hzwVideoClip.size)
    finalClip = CompositeVideoClip([hzwVideoClip, animationClip.set_start(5)])
    finalClip.write_videofile(output_file_path, fps=25, codec="libx264", audio_codec="aac")
